import QtQuick 2.6

/* Usage :
  ImagePicker {
      id:picker
      onAccepted:image.srouce = fileUrl
  }
  Image {
      id:image
  }
  MouseArea {
      onClicked: picker.open()
  }
  */
Item {
    id:root
    property url fileUrl

    function open()
    {
        loader.item.open()
    }
    function close()
    {
        loader.item.close()
    }

    signal accepted
    signal rejected
    signal error

    visible: false

    Loader {
        id:loader
        anchors.fill: parent
        source: Qt.platform.os === "android" ? "ImagePicker_Android.qml" : "ImagePicker_Normal.qml"
        Connections {
            target: loader.item
            ignoreUnknownSignals: true
            onAccepted: {
                root.fileUrl = loader.item.fileUrl
                root.accepted()
            }
            onRejected: root.rejected()
            onError: root.error()
        }
    }
}
